version 16
set more off

***********************************************************************************************************************
* THIS ROUTINE GENERATES FIGURE A.VI OF WASEEM (2020) ROLE OF WITHHOLDING ...
***********************************************************************************************************************

/* ENTRY */

use					"$project_data\STPAK_1996_2011_UBP_v1.dta", clear
keep              if business_sts=="1" 
merge					m:1 regno using "$project_data\Master Short Updated Nov 2011.dta", keepusing(date_comm)
drop					if _merge==2
bys					regno:egen entry=min(taxperiod)
g						entrymonth=mofd(taxperiod)
g						regmonth=mofd(date_comm)
g						regmt6m=entrymonth>regmonth+6
keep					regno entry taxperiod fy item_cd business_sts tot_sale tot_purch regmt6m 
g						ind=real(substr(item_cd,1,4))
drop					if ind<1600
drop					if ind>=2500 & ind<2800
g 						period=mofd(entry)
qui					sum period
replace				period=period-r(min)+1
duplicates 			drop regno, force
bys					period:egen prop_regmt6m=mean(regmt6m)
replace				prop_regmt6m=prop_regmt6m*100
bys					period:g index=_n
#d;
twoway  				(line  prop_regmt6m period if period >24 & period<=108 & index==1,sort lwidth(thick) lcolor(red) mcolor(red) msymbol(O)),
						xtitle("Entry Period") xscale(titlegap(*10))
						xlabel(25 "1998" 37 "1999" 49 "2000" 61 "2001" 73 "2002" 85 "2003" 97 "2004" 109 "2005")
						xline(37 49, lpatter(dash) lcolor(green)) ytitle(Proportion Registered At Least Six Months Ago (%), alignment(bottom)) 
						ylabel(0(20)100)  yscale(titlegap(*10))
						graphregion(fcolor(white) style(none) color(white) margin(0 2 0 2)) bgcolor(white); 	
graph 				export "$project_output\ProportionRegistermtoneyr_By_Entry.eps", replace;
#d						cr